#define _CRT_SECURE_NO_WARNINGS 1
//#include <stdio.h>
//#include <stddef.h>
//
////struct S
//{
//	char c1;
//	int i;
//	char c2;
//};
//int main()
//{
//	printf("%d\n", offsetof(struct S, c1));
//	printf("%d\n", offsetof(struct S, i));
//	printf("%d\n", offsetof(struct S, c2));
//
//	return 0;
//}

//#define OFFSETOF(type, member) &(((type*)0)->member)
//struct S
//{
//	char c1;
//	int i;
//	char c2;
//};
//int main()
//{
//	printf("%p\n", OFFSETOF(struct S, c1));
//	printf("%p\n", OFFSETOF(struct S, i));
//	printf("%p\n", OFFSETOF(struct S, c2));
//
//	return 0;
//}
//

//#define SWAP(n) (n=((n&0xaaaaaaaa)>>1)+((n&0x55555555)<<1))
//int main()
//{
//	int a = 10;
//	SWAP(a);
//	printf("%d\n", a);
//	return 0;
//}

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

class Solution {
public:
    string largestNumber(vector<int>& nums) {
        vector<string> strs;
        for (int i = 0; i < nums.size(); i++)
        {
            string s = to_string(nums[i]);
            strs.push_back(s);
        }
        //
        sort(strs.begin(), strs.end(), [](string& s1, string& s2) {
            return s1 + s2 > s2 + s1;
            });
        //
        string ret;
        for (auto& e : strs) ret += e;
        if (strs[0] == "0") return "0";
        return ret;
    }
};

int main()
{
    Solution s;
    vector<int> v = { 3,30,34,5,9 };
    string k = s.largestNumber(v);
    cout << k << endl;
    return 0;
}